package br.com.relatorios.entity;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

@MappedSuperclass
public abstract class BaseEntity implements Serializable {

//==========================================
// Atributos estaticos / enum / arrays 
//==========================================
	

//==========================================
// Atributos privados
//==========================================

	private Long id;
	private Date dataHoraInclusao;
	private Date dataHoraAlteracao;
	

//==========================================
// Chaves Primarias
//==========================================

	@Id 
	@GeneratedValue 
	@Column(name = "id") 
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
//==========================================
// 	Atributos persistentes ( gets e sets )
//==========================================
	
	@Column(name="datahorainc", nullable=false)
    @Basic @Temporal(TemporalType.TIMESTAMP)  	
	public Date getDataHoraInclusao() {
		return dataHoraInclusao;
	}
	public void setDataHoraInclusao(Date dataHoraInclusao) {
		this.dataHoraInclusao = dataHoraInclusao;
	}

	@Column(name="datahoraalt", nullable=false)
    @Basic @Temporal(TemporalType.TIMESTAMP)  	
	public Date getDataHoraAlteracao() {
		return dataHoraAlteracao;
	}
	public void setDataHoraAlteracao(Date dataHoraAlteracao) {
		this.dataHoraAlteracao = dataHoraAlteracao;
	}
	
	@Override
	public boolean equals(Object object) {
        if (!(object instanceof BaseEntity)) {
            return false;
        }
        BaseEntity other = (BaseEntity) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.getId().equals(other.getId()))) {
            return false;
        }
        return true;
    }
	
	@Override
	public int hashCode() {
		int hash = 0;
	    hash += (id != null ? id.hashCode() : 0);
	    return hash;
	}	  

	public String toString() {
	    StringBuilder s = new StringBuilder();
	    s.append(super.getClass().getName()).append("[id = ").append(getId()).append(" ]");
	    return s.toString();
	}	
	
}
